package com.FengChaoSystem.untils;

import io.jsonwebtoken.*;

import java.util.Date;
import java.util.Map;

/**
 * jwt鉴权工具类
 */
public class JwtUtil {
    private static long time=1000*60*60*24;
    private static String signature="user";

    public static String buildJWT(Map<String,Object>claims){
        String jwt = Jwts.builder()
                .addClaims(claims)
                .signWith(SignatureAlgorithm.HS256, signature)
                .setExpiration(new Date(System.currentTimeMillis() + time))
                .compact();
        return jwt;

    }
    public static void parse(String token){
        Claims claims = Jwts.parser()
                .setSigningKey(signature)
                .parseClaimsJws(token)
                .getBody();
    }
}
